In [1]:
import sys
sys.path.insert(0, '../..')
import base_node_rpc as bn
import rpc_stream as rs
import pandas as pd
from IPython.display import display
In [2]:
proxy = bn.proxy.connect(rs.Proxy, name='rpc_stream')
print 'Connected to device on port:', proxy._serial.port
proxy.properties()
Out[2]:
Note that stream responses are processed automatically in the background, and added
to a stream
queue.
In [3]:
for i in range(4):
proxy.stream_echo('hello %s' % i, 2)
In [4]:
packets = [list(proxy.queues.stream.get()) for i in xrange(proxy.queues.stream.qsize())]
if packets:
df_packets = pd.DataFrame(packets, columns=['timestamp', 'packet'])
df_packets['iuid'] = df_packets.packet.map(lambda p: p.iuid)
df_packets['data'] = df_packets.packet.map(lambda p: p.data())
display(df_packets)
# display(df_packets.groupby('iuid').agg({'data': lambda v: ''.join(v)}))